def procedureName(): |
def procedureName2(): |
print("Cya") |
procedureName() |
print("Sup") |
procedureName2() |
def procedureName(): |
def procedureName2(): |
    print("Cya") |
procedureName() |
    print("Sup") |
procedureName2() |
1 | def procedureName(): |
2 |     print("Sup") |
3 | |
4 | def procedureName2(): |
5 |     print("Cya") |
6 |      |
7 | procedureName() |
8 | procedureName2() |
def printHello(): |
print("Hello World!") |
printHello() |
def printHello(): |
    print("Hello World!") |
printHello() |
1 | def printHello(): |
2 |     print("Hello World!") |
3 | printHello() |
def printOne(): |
def printTwo(): |
printTwo() |
printOne() |
def printThree(): |
print(3) |
print(2) |
printThree() |
print(1) |
def printOne(): |
def printTwo(): |
printTwo() |
printOne() |
def printThree(): |
    print(3) |
    print(2) |
printThree() |
    print(1) |
1 | def printOne(): |
2 |     print(1) |
3 | |
4 | def printTwo(): |
5 |     print(2) |
6 | |
7 | def printThree(): |
8 |     print(3) |
9 | |
10 | printOne() |
11 | printTwo() |
12 | printThree() |
def doMaths(a): |
print(a/5) |
doMaths(40) |
def doMaths(a): |
    print(a/5) |
doMaths(40) |
1 | def doMaths(a): |
2 |     print(a/5) |
3 | doMaths(40) |
addFive(10) |
print(a+5) |
def addFive(a): |
addFive(10) |
    print(a+5) |
def addFive(a): |
1 | def addFive(a): |
2 |     print(a+5) |
3 | addFive(10) |
for x in range(5): |
printLoop() |
def printLoop(): |
print("loop") |
    for x in range(5): |
printLoop() |
def printLoop(): |
        print("loop") |
1 | def printLoop(): |
2 |     for x in range(5): |
3 |         print("loop") |
4 | printLoop() |
printLoop(10) |
for x in range(a): |
def printLoop(a): |
print("loop") |
printLoop(10) |
    for x in range(a): |
def printLoop(a): |
        print("loop") |
1 | def printLoop(a): |
2 |     for x in range(a): |
3 |         print("loop") |
4 | printLoop(10) |
doMaths(3,4) |
def doMaths(a,b): |
print(a*b) |
doMaths(3,4) |
def doMaths(a,b): |
    print(a*b) |
1 | def doMaths(a,b): |
2 |     print(a*b) |
3 | doMaths(3,4) |
def doMaths(a,b): |
doMaths(2,6) |
print(a*b) |
def doMaths(a,b): |
doMaths(2,6) |
    print(a*b) |
1 | def doMaths(a,b): |
2 |     print(a*b) |
3 | doMaths(2,6) |
def addNums(a,b): |
addNums(1,7) |
addNums(5,3) |
addNums(6,2) |
print(a + b) |
addNums(4,4) |
def addNums(a,b): |
addNums(1,7) |
addNums(5,3) |
addNums(6,2) |
    print(a + b) |
addNums(4,4) |
1 | def addNums(a,b): |
2 |     print(a + b) |
3 | |
4 | addNums(6,2) |
5 | addNums(4,4) |
6 | addNums(5,3) |
7 | addNums(1,7) |
print(a) |
a = a + 0.5 |
def roundNum(a): |
roundNum(5.2) |
a = int(a) |
    print(a) |
    a = a + 0.5 |
def roundNum(a): |
roundNum(5.2) |
    a = int(a) |
1 | def roundNum(a): |
2 |     a = a + 0.5 |
3 |     a = int(a) |
4 |     print(a) |
5 | roundNum(5.2) |
print("Go!") |
def countdown(): |
time.sleep(1) |
countdown() |
time.sleep(1) |
print("3") |
print("2") |
import time |
time.sleep(1) |
print("1") |
    print("Go!") |
def countdown(): |
    time.sleep(1) |
countdown() |
    time.sleep(1) |
    print("3") |
    print("2") |
import time |
    time.sleep(1) |
    print("1") |
1 | import time |
2 | def countdown(): |
3 |     print("3") |
4 |     time.sleep(1) |
5 |     print("2") |
6 |     time.sleep(1) |
7 |     print("1") |
8 |     time.sleep(1) |
9 |     print("Go!") |
10 | countdown() |
printNums(10) |
for x in range(1,a+1): |
print(x) |
printNums(5) |
def printNums(a): |
printNums(10) |
    for x in range(1,a+1): |
        print(x) |
printNums(5) |
def printNums(a): |
1 | def printNums(a): |
2 |     for x in range(1,a+1): |
3 |         print(x) |
4 | |
5 | printNums(5) |
6 | printNums(10) |
printNums(30) |
printNums(20) |
for x in range(1,a+1): |
print(x) |
printNums(10) |
def printNums(a): |
printNums(30) |
printNums(20) |
    for x in range(1,a+1): |
        print(x) |
printNums(10) |
def printNums(a): |
1 | def printNums(a): |
2 |     for x in range(1,a+1): |
3 |         print(x) |
4 | |
5 | printNums(10) |
6 | printNums(20) |
7 | printNums(30) |
print(e) |
for x in range(1,a+1): |
e = e + str(x) |
printNumRow(7) |
def printNumRow(a): |
e = "" |
if x == a: #The last index |
e = e + str(x) + "," |
else: |
    print(e) |
    for x in range(1,a+1): |
            e = e + str(x) |
printNumRow(7) |
def printNumRow(a): |
    e = "" |
        if x == a: #The last index |
            e = e + str(x) + "," |
        else: |
1 | def printNumRow(a): |
2 |     e = "" |
3 |     for x in range(1,a+1): |
4 |         if x == a: #The last index |
5 |             e = e + str(x) |
6 |         else: |
7 |             e = e + str(x) + "," |
8 |     print(e) |
9 | printNumRow(7) |
def printSquare(a,b): |
for x in range(a): |
printSquare(7,5) |
print(s) |
for y in range(b): |
s = s + "#" |
s = "" |
def printSquare(a,b): |
    for x in range(a): |
printSquare(7,5) |
        print(s) |
    for y in range(b): |
        s = s + "#" |
    s = "" |
1 | def printSquare(a,b): |
2 |     s = "" |
3 |     for x in range(a): |
4 |         s = s + "#" |
5 |     for y in range(b): |
6 |         print(s) |
7 | printSquare(7,5) |
print("King of " + suit) |
print("Queen of " + suit) |
if num == 1: |
elif num == 13: |
print("Ace of " + suit) |
def printCard(a): |
printCard([4,"Hearts"]) |
printCard([1,"Spades"]) |
suit = a[1] |
elif num == 12: |
print("Jack of " + suit) |
else: |
num = a[0] |
elif num == 11: |
print(str(num) + " of" + suit) |
        print("King of " + suit) |
        print("Queen of " + suit) |
    if num == 1: |
    elif num == 13: |
        print("Ace of " + suit) |
def printCard(a): |
printCard([4,"Hearts"]) |
printCard([1,"Spades"]) |
    suit = a[1] |
    elif num == 12: |
        print("Jack of " + suit) |
    else: |
    num = a[0] |
    elif num == 11: |
        print(str(num) + " of" + suit) |
1 | def printCard(a): |
2 |     num = a[0] |
3 |     suit = a[1] |
4 |     if num == 1: |
5 |         print("Ace of " + suit) |
6 |     elif num == 11: |
7 |         print("Jack of " + suit) |
8 |     elif num == 12: |
9 |         print("Queen of " + suit) |
10 |     elif num == 13: |
11 |         print("King of " + suit) |
12 |     else: |
13 |         print(str(num) + " of" + suit) |
14 | |
15 | printCard([4,"Hearts"]) |
16 | printCard([1,"Spades"]) |
print(str(a[x]) + " = " + str(b[x])) |
printTogether(["A","B","C"],[1,2,3]) |
def printTogether(a,b): |
for x in range(len(a)): |
        print(str(a[x]) + " = " + str(b[x])) |
printTogether(["A","B","C"],[1,2,3]) |
def printTogether(a,b): |
    for x in range(len(a)): |
1 | def printTogether(a,b): |
2 |     for x in range(len(a)): |
3 |         print(str(a[x]) + " = " + str(b[x])) |
4 | printTogether(["A","B","C"],[1,2,3]) |
break |
a = a + b |
e = e + str(a) + ", " |
def printSequence(a,b,c): |
c = c - 1 |
while True: |
printSequence(5,4,10) |
print(e[:len(e)-1]) #removes the last , |
if c == 0: |
e = "" |
            break |
        a = a + b |
        e = e + str(a) + ", " |
def printSequence(a,b,c): |
        c = c - 1 |
    while True: |
printSequence(5,4,10) |
    print(e[:len(e)-1]) #removes the last , |
        if c == 0: |
    e = "" |
1 | def printSequence(a,b,c): |
2 |     e = "" |
3 |     while True: |
4 |         if c == 0: |
5 |             break |
6 |         e = e + str(a) + ", " |
7 |         a = a + b |
8 |         c = c - 1 |
9 |     print(e[:len(e)-1]) #removes the last , |
10 |          |
11 | printSequence(5,4,10) |
12 |      |
highest = a |
print(num) |
biggestMultiple(30,30) |
highest = b |
for x in range(highest): |
if b > a: |
if a % num == 0 and b % num == 0: |
num = highest - x |
def biggestMultiple(a,b): |
break |
    highest = a |
            print(num) |
biggestMultiple(30,30) |
        highest = b |
    for x in range(highest): |
    if b > a: |
        if a % num == 0 and b % num == 0: |
        num = highest - x |
def biggestMultiple(a,b): |
            break |
1 | def biggestMultiple(a,b): |
2 |     highest = a |
3 |     if b > a: |
4 |         highest = b |
5 |     for x in range(highest): |
6 |         num = highest - x |
7 |         if a % num == 0 and b % num == 0: |
8 |             print(num) |
9 |             break |
10 | biggestMultiple(30,30) |
l = len(fib) - 1 |
else: |
printFibonacci(4) |
fib.append(fib[l] + fib[l-1]) |
fib = [] |
l = len(fib) - 1 |
def printFibonacci(n): |
if x == 0 or x == 1: |
for x in range(n): |
fib.append(1) |
print(fib[l]) |
    l = len(fib) - 1 |
        else: |
printFibonacci(4) |
            fib.append(fib[l] + fib[l-1]) |
    fib = [] |
            l = len(fib) - 1 |
def printFibonacci(n): |
        if x == 0 or x == 1: |
    for x in range(n): |
            fib.append(1) |
    print(fib[l]) |
1 | def printFibonacci(n): |
2 |     fib = [] |
3 |     for x in range(n): |
4 |         if x == 0 or x == 1: |
5 |             fib.append(1) |
6 |         else: |
7 |             l = len(fib) - 1 |
8 |             fib.append(fib[l] + fib[l-1]) |
9 |     l = len(fib) - 1 |
10 |     print(fib[l]) |
11 | printFibonacci(4) |
print(sentence) |
else: |
sentence = sentence + text[x] + " " |
print(sentence) |
def wordWrap(s): |
sentence = text[x] + " " |
sentence = "" |
for x in range(len(text)): |
if len(sentence) + len(text[x]) > 25: |
text = s.split(" ") |
wordWrap("This is a program that uses procedures to display stuff on the screen") |
    print(sentence) |
        else: |
            sentence = sentence + text[x] + " " |
            print(sentence) |
def wordWrap(s): |
            sentence = text[x] + " " |
    sentence = "" |
    for x in range(len(text)): |
        if len(sentence) + len(text[x]) > 25: |
    text = s.split(" ") |
wordWrap("This is a program that uses procedures to display stuff on the screen") |
1 | |
2 | def wordWrap(s): |
3 |     text = s.split(" ") |
4 |     sentence = "" |
5 |     for x in range(len(text)): |
6 |         if len(sentence) + len(text[x]) > 25: |
7 |             print(sentence) |
8 |             sentence = text[x] + " " |
9 |         else: |
10 |             sentence = sentence + text[x] + " " |
11 |     print(sentence) |
12 | wordWrap("This is a program that uses procedures to display stuff on the screen") |
summaryArr(["bread","apple","apple","lemon"]) |
def summaryArr(arr): |
items.append(arr[x]) |
count[i] = count[i] + 1 |
count.append(1) |
else: |
for x in range(len(items)): |
print(items[x] + ": " + str(count[x])) |
i = items.index(arr[x]) |
for x in range(len(arr)): |
items = [] |
if arr[x] not in items: |
count = [] |
summaryArr(["bread","apple","apple","lemon"]) |
def summaryArr(arr): |
            items.append(arr[x]) |
            count[i] = count[i] + 1 |
            count.append(1) |
        else: |
    for x in range(len(items)): |
        print(items[x] + ": " + str(count[x])) |
            i = items.index(arr[x]) |
    for x in range(len(arr)): |
    items = [] |
        if arr[x] not in items: |
    count = [] |
1 | def summaryArr(arr): |
2 |     items = [] |
3 |     count = [] |
4 |     for x in range(len(arr)): |
5 |         if arr[x] not in items: |
6 |             items.append(arr[x]) |
7 |             count.append(1) |
8 |         else: |
9 |             i = items.index(arr[x]) |
10 |             count[i] = count[i] + 1 |
11 |     for x in range(len(items)): |
12 |         print(items[x] + ": " + str(count[x])) |
13 | summaryArr(["bread","apple","apple","lemon"]) |
printDown(a-1) |
printDown(5) |
print(a) |
if a != 0: |
def printDown(a): |
printDown(8) |
        printDown(a-1) |
printDown(5) |
        print(a) |
    if a != 0: |
def printDown(a): |
printDown(8) |
1 | def printDown(a): |
2 |     if a != 0: |
3 |         print(a) |
4 |         printDown(a-1) |
5 | |
6 | printDown(8) |
7 | printDown(5) |
print(a) |
doubleNumber(10,4) |
a = a * 2 |
if b != 0: |
doubleNumber(a,b) |
print() |
def doubleNumber(a,b): |
doubleNumber(30,2) |
b = b - 1 |
        print(a) |
doubleNumber(10,4) |
        a = a * 2 |
    if b != 0: |
        doubleNumber(a,b) |
print() |
def doubleNumber(a,b): |
doubleNumber(30,2) |
        b = b - 1 |
1 | def doubleNumber(a,b): |
2 |     if b != 0: |
3 |         b = b - 1 |
4 |         a = a * 2 |
5 |         print(a) |
6 |         doubleNumber(a,b) |
7 | |
8 | doubleNumber(10,4) |
9 | print() |
10 | doubleNumber(30,2) |
printArrayItems(a) |
print(b) |
if len(a) != 0: |
def printArrayItems(a): |
printArrayItems([1,2,3]) |
b = a.pop(0) |
print() |
printArrayItems([3,2,1]) |
        printArrayItems(a) |
        print(b) |
    if len(a) != 0: |
def printArrayItems(a): |
printArrayItems([1,2,3]) |
        b = a.pop(0) |
print() |
printArrayItems([3,2,1]) |
1 | def printArrayItems(a): |
2 |     if len(a) != 0: |
3 |         b = a.pop(0) |
4 |         print(b) |
5 |         printArrayItems(a) |
6 | |
7 | printArrayItems([1,2,3]) |
8 | print() |
9 | printArrayItems([3,2,1]) |
print() |
b = b[1:] |
print(a) |
def binaryConvert(b,a=0): |
if z == "1": |
else: |
if len(b) > 0: |
binaryConvert("11110000") |
binaryConvert("10101111") |
else: |
power = len(b) |
binaryConvert(b,a) |
z = b[0] |
a = a + 2 ** power |
binaryConvert(b,a) |
print() |
        b = b[1:] |
        print(a) |
def binaryConvert(b,a=0): |
        if z == "1": |
        else: |
    if len(b) > 0: |
binaryConvert("11110000") |
binaryConvert("10101111") |
    else: |
            power = len(b) |
            binaryConvert(b,a) |
        z = b[0] |
            a = a + 2 ** power |
            binaryConvert(b,a) |
1 | def binaryConvert(b,a=0): |
2 |     if len(b) > 0: |
3 |         z = b[0] |
4 |         b = b[1:] |
5 |         if z == "1": |
6 |             power = len(b) |
7 |             a = a + 2 ** power |
8 |             binaryConvert(b,a) |
9 |         else: |
10 |             binaryConvert(b,a) |
11 |     else: |
12 |         print(a) |
13 |          |
14 |          |
15 |      |
16 | binaryConvert("10101111") |
17 | print() |
18 | binaryConvert("11110000") |
div = n // 2 |
def denaryConvert(n,a=""): |
denaryConvert(div,a) |
else: |
if n != 0: |
rem = n % 2 |
print(a) |
print() |
denaryConvert(240) |
a = str(rem) + a |
denaryConvert(175) |
        div = n // 2 |
def denaryConvert(n,a=""): |
        denaryConvert(div,a) |
    else: |
    if n != 0: |
        rem = n % 2 |
        print(a) |
print() |
denaryConvert(240) |
        a = str(rem) + a |
denaryConvert(175) |
1 | def denaryConvert(n,a=""): |
2 |     if n != 0: |
3 |         div = n // 2 |
4 |         rem = n % 2 |
5 |         a = str(rem) + a |
6 |         denaryConvert(div,a) |
7 |     else: |
8 |         print(a) |
9 | |
10 | denaryConvert(175) |
11 | print() |
12 | denaryConvert(240) |